/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Conexion;
import java.sql.*;
/**
 *
 * @author GJ_ASPRILLA
 */
public class SQLServerTest {
    public SQLServerTest()
{
   Connection connection = null;
   try 
   { 
      // Get connection
      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
      connection = DriverManager.getConnection("jdbc:sqlserver://172.20.8.242","agromapas","Agr0mapas");
      if (connection != null) 
      {
         System.out.println("Successfully connected");
         // Meta data
         DatabaseMetaData meta = connection.getMetaData();
         System.out.println("\nDriver Information");
         System.out.println("Driver Name: " + meta.getDriverName());
         System.out.println("Driver Version: " + meta.getDriverVersion());
         System.out.println("nDatabase Information ");
         System.out.println("Database Name: " + meta.getDatabaseProductName());
         System.out.println("Database Version: " + meta.getDatabaseProductVersion());
      }
   }
   catch (ClassNotFoundException e)
   {
      System.out.println("No se encontró el controlador: " + e.getMessage());
   }
   catch (SQLException e)
   { 
      System.out.println("Error en la base de datos: " + e.getMessage());
   }
   
}
 
  // Test
  public static void main (String args[]) throws Exception  
  {
     SQLServerTest test = new SQLServerTest();
  }
  }

